package encapsulation;

public class Person {

    private String name;
    private String gender;
    private int age;

    Person(){
        System.out.println("一个人从世界上诞生了...");
    }

    public Person(String name, String gender, int age) {
        this();
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }


    public int getAge() {
        if("女".equals(this.gender)){
            return 18;
        }
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + this.getName() + '\'' +
                ", gender='" + this.getGender() + '\'' +
                ", age=" + this.getAge() +
                '}';
    }
}
